package com.hmy.finance.service.receipt.dto.customerAccount;

import com.hmy.finance.api.common.enums.receipt.AccountTradeBusinessTypeEnum;
import com.hmy.finance.api.common.enums.receipt.AccountTradeTypeEnum;
import com.hmy.finance.dal.po.receipt.CustomerBalanceAccountPo;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 构建客户账户流水参数
 *
 * @author songkf
 */
@Data
public class CustomerTradeDto implements java.io.Serializable {
    private static final long serialVersionUID = 750795217782260797L;

    //======================= Request Parameters =======================

    /**
     * 客户余额账户
     */
    private CustomerBalanceAccountPo customerBalanceAccount;

    /**
     * 入账金额
     */
    private BigDecimal amount;

    /**
     * 业务类型
     */
    private AccountTradeBusinessTypeEnum businessType;

    /**
     * 业务单据号
     */
    private Long businessBillId;

    /**
     * 费用发生日期
     */
    private LocalDateTime feeIncurredTime;

    /**
     * 流水类型
     */
    private AccountTradeTypeEnum tradeType;

    public static CustomerTradeDto buildFromIncomeDto(CustomerIncomeDto customerIncomeDto) {
        CustomerTradeDto customerTradeDto = new CustomerTradeDto();
        customerTradeDto.setCustomerBalanceAccount(customerIncomeDto.getCustomerBalanceAccountPo());
        customerTradeDto.setAmount(customerIncomeDto.getAmount());
        customerTradeDto.setBusinessType(customerIncomeDto.getBusinessType());
        customerTradeDto.setBusinessBillId(customerIncomeDto.getBusinessBillId());
        customerTradeDto.setFeeIncurredTime(customerIncomeDto.getFeeIncurredTime());
        customerTradeDto.setTradeType(AccountTradeTypeEnum.INCOME);
        return customerTradeDto;
    }

    public static CustomerTradeDto buildFromExpensesDto(CustomerExpensesDto customerExpensesDto) {
        CustomerTradeDto customerTradeDto = new CustomerTradeDto();
        customerTradeDto.setCustomerBalanceAccount(customerExpensesDto.getCustomerBalanceAccountPo());
        customerTradeDto.setAmount(customerExpensesDto.getAmount());
        customerTradeDto.setBusinessType(customerExpensesDto.getBusinessType());
        customerTradeDto.setBusinessBillId(customerExpensesDto.getBusinessBillId());
        customerTradeDto.setFeeIncurredTime(customerExpensesDto.getFeeIncurredTime());
        customerTradeDto.setTradeType(AccountTradeTypeEnum.EXPENSES);
        return customerTradeDto;
    }

}
